package com.lemurian.entity;
// Generated Jan 13, 2012 10:56:58 AM by Hibernate Tools 3.2.1.GA

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.OrderBy;

import com.lemurian.entity.utils.DefaultPersistence;

/**
 * Users generated by aditya
 */
@Entity
@Table(name = "tb_user", uniqueConstraints = {@UniqueConstraint(columnNames = "loginId")})
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@BatchSize(size=100)
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class User extends DefaultPersistence implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private String loginId = "";
    private String password;
    private String password1;
    private String password2;
    private String password3;
    private String password4;
    private String password5;
    private String name;
    private String email;
    private int failCount;
    private Character status;
    private Date birthDate;
    private Date registerDate;
    private Date passwordValidDate;
    private String sessionId;
    private Date sessionValidTime;
    private String phone1;
    private String phone2;
    private String address1;
    private String address2;
    private String zipCode;
    private String fax;
    private String mobilePhone;
    private String city;
    
    @ManyToOne()
    @JoinColumn(name = "user_type_id")
    private Category userType;
    
    @ManyToOne()
    @JoinColumn(name="organization_id")
    private Organization organization;
    
    @ManyToMany(fetch = FetchType.EAGER)
    @Fetch(FetchMode.SELECT)
    @JoinTable(
    		name = "tb_user_group", 
    		joinColumns = {@JoinColumn(name = "user_id")}, 
    		inverseJoinColumns = {@JoinColumn(name = "group_id")},
			uniqueConstraints={@UniqueConstraint(columnNames={"user_id","group_id"})}
    	)
    @BatchSize(size=100)
    @OrderBy(clause = "group_id asc")
    private Set<Groups> groups = new HashSet<Groups>();

    @ManyToOne()
    @JoinColumn(name = "departement_id")
    private Category department;
    
    public Category getUserType() {
        return this.userType;
    }

    public void setUserType(Category userType) {
        this.userType = userType;
    }

    @Column(name = "login_id", unique = true, length = 32)
    public String getLoginId() {
        return this.loginId;
    }

    public void setLoginId(String loginId) {
        this.loginId = loginId;
    }

    @Column(name = "password", length = 256)
    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "name", length = 64)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "email", length = 64)
    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Column(name = "phone1", length = 16)
    public String getPhone1() {
        return this.phone1;
    }

    public void setPhone1(String phone1) {
        this.phone1 = phone1;
    }

    @Column(name = "fail_count")
    public int getFailCount() {
        return this.failCount;
    }

    public void setFailCount(int failCount) {
        this.failCount = failCount;
    }

    @Column(name = "status", length = 1)
    public Character getStatus() {
        return this.status;
    }

    public void setStatus(Character status) {
        this.status = status;
    }

    @Temporal(value = TemporalType.TIMESTAMP)
    @Column(name = "register_date", length = 29)
    public Date getRegisterDate() {
        return this.registerDate;
    }

    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }

    @Temporal(value = TemporalType.TIMESTAMP)
    @Column(name = "password_valid_date", length = 29)
    public Date getPasswordValidDate() {
        return this.passwordValidDate;
    }

    public void setPasswordValidDate(Date passwordValidDate) {
        this.passwordValidDate = passwordValidDate;
    }

    public Set<Groups> getGroups() {
        return this.groups;
    }

    public void setGroups(Set<Groups> groups) {
        this.groups = groups;
    }

    /**
     * @return the password1
     */
    @Column(name = "password1", length = 256)
    public String getPassword1() {
        return password1;
    }

    /**
     * @param password1 the password1 to set
     */
    public void setPassword1(String password1) {
        this.password1 = password1;
    }

    /**
     * @return the password2
     */
    @Column(name = "password2", length = 256)
    public String getPassword2() {
        return password2;
    }

    /**
     * @param password2 the password2 to set
     */
    public void setPassword2(String password2) {
        this.password2 = password2;
    }

    /**
     * @return the password3
     */
    @Column(name = "password3", length = 256)
    public String getPassword3() {
        return password3;
    }

    /**
     * @param password3 the password3 to set
     */
    public void setPassword3(String password3) {
        this.password3 = password3;
    }

    /**
     * @return the password4
     */
    @Column(name = "password4", length = 256)
    public String getPassword4() {
        return password4;
    }

    /**
     * @param password4 the password4 to set
     */
    public void setPassword4(String password4) {
        this.password4 = password4;
    }

    /**
     * @return the password5
     */
    @Column(name = "password5", length = 256)
    public String getPassword5() {
        return password5;
    }

    /**
     * @param password5 the password5 to set
     */
    public void setPassword5(String password5) {
        this.password5 = password5;
    }

    /**
     * @return the phone2
     */
    @Column(name = "phone2", length = 16)
    public String getPhone2() {
        return phone2;
    }

    /**
     * @param phone2 the phone2 to set
     */
    public void setPhone2(String phone2) {
        this.phone2 = phone2;
    }

    /**
     * @return the address1
     */
    @Column(name = "address1", length = 256)
    public String getAddress1() {
        return address1;
    }

    /**
     * @param address1 the address1 to set
     */
    public void setAddress1(String address1) {
        this.address1 = address1;
    }

    /**
     * @return the address2
     */
    @Column(name = "address2", length = 256)
    public String getAddress2() {
        return address2;
    }

    /**
     * @param address2 the address2 to set
     */
    public void setAddress2(String address2) {
        this.address2 = address2;
    }

    /**
     * @return the fax
     */
    @Column(name = "fax", length = 16)
    public String getFax() {
        return fax;
    }

    /**
     * @param fax the fax to set
     */
    public void setFax(String fax) {
        this.fax = fax;
    }

    /**
     * @return the mobilePhone
     */
    @Column(name = "mobile_phone", length = 16)
    public String getMobilePhone() {
        return mobilePhone;
    }

    /**
     * @param mobilePhone the mobilePhone to set
     */
    public void setMobilePhone(String mobilePhone) {
        this.mobilePhone = mobilePhone;
    }

    /**
     * @return the zipCode
     */
    @Column(name = "zip_code", length = 6)
    public String getZipCode() {
        return zipCode;
    }

    /**
     * @param zipCode the zipCode to set
     */
    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    /**
     * @return the city
     */
    @Column(name = "city", length = 16)
    public String getCity() {
        return city;
    }

    /**
     * @param city the city to set
     */
    public void setCity(String city) {
        this.city = city;
    }

    @Column(name = "session_id", length = 256)
    public String getSessionId() {
        return this.sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "session_valid_time", length = 29)
    public Date getSessionValidTime() {
        return this.sessionValidTime;
    }

    public void setSessionValidTime(Date sessionValidTime) {
        this.sessionValidTime = sessionValidTime;
    }

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	@Temporal(TemporalType.TIMESTAMP)
    @Column(name="birthDate")
	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	public Category getDepartment() {
		return department;
	}

	public void setDepartment(Category department) {
		this.department = department;
	}
	
}